package pwd.allen.aop.advice;

import org.springframework.aop.AfterReturningAdvice;

import java.lang.reflect.Method;
import java.util.Arrays;

/**
 * 后置返回通知：在连接点的方法调用完成并返回结果后执行
 * 无法修改返回值；如果目标方法抛出异常，则不会运行后置返回通知
 *
 * @author 门那粒沙
 * @create 2020-08-30 12:11
 **/
public class MyAfterReturningAdvice implements AfterReturningAdvice {
    @Override
    public void afterReturning(Object returnValue, Method method, Object[] args, Object target) throws Throwable {
        System.out.println(String.format("【AfterReturningAdvice】After '%s',args = %s,return = %s", method.getName(), Arrays.toString(args), returnValue));
    }
}
